<template>
<div>
  <el-upload
  :action="uploadUrl"
  list-type="picture-card"
  :on-preview="handlePictureCardPreview"
  :on-remove="handleRemove"
  :on-success="handleSuccess"
  :file-list="fileList"
  ref="upload"
  multiple
  >
  
  <i class="el-icon-plus"></i>
</el-upload>
</div>
</template>

<script>
import {uploadUrl,host} from '@/api/base'
  export default {
    props:{
      fileList:{
        type:Array,
        default:function(){
          return []
        }
      }
    },
    data() {
      return {
        uploadUrl,
        // fileList:[],//上传的列表
        // dialogImageUrl: '',
        // dialogVisible: false
      };
    },
    methods: {
      handleSuccess(response, file, fileList){
           let url = response.url.slice(7);
            let imgUrl = host+'/'+url
            // console.log('url',imgUrl);
            this.$emit('sendImg',imgUrl)
            
      },
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePictureCardPreview(file) {
        this.dialogImageUrl = file.url;
        this.dialogVisible = true;
      },
      clear(){
        this.$refs.upload.clearFiles();
      }
    }
  }
</script>

<style>

</style>